package Demo;

public class Test2 {
    public void func1(){
        class Inner{//局部内部类，定义在方法内部且不能被static，public修饰，只能在方法内部使用
            public int data1 = 1;
        }
        Inner inner = new Inner();
        System.out.println(inner.data1);
    }
    public static void main(String[] args) {
        Outter2.Inner inner = new Outter2.Inner();//不依赖对象的引用
        inner.test();
    }
}
class Outter2{
    public int data1 = 1;
    private int data2 = 2;
    static  int data3 = 3;
    static class Inner{
        public int data4 = 4;
        private  int data5 = 5;
        public static  int data6 = 6;
        public void test(){
            //System.out.println(data1);    没有外部类对象，根本就拿不到data1，因此不能直接访问
            Outter outter = new Outter();
            System.out.println(outter.data1);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
            System.out.println("内部类的test方法");
        }
    }
}